name: Tests

on:
  push:
    branches:
    - 'master'
  pull_request:
    branches:
    - '*'

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false  # don't cancel if a job from the matrix fails
      matrix:
        compiler:
          - { compiler: GNU,  CC: gcc,   CXX: g++, FORMAT: ON }
          - { compiler: LLVM, CC: clang, CXX: clang++, FORMAT: OFF }
        #flavor: [ Release, Coverage ] # TODO
        flavor: [ Release ]
        exclude:
          - compiler: { compiler: LLVM, CC: clang, CXX: clang++ }
            flavor: Coverage

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: 'recursive'
      - name: Install Dependencies
        run: |
          sudo apt install -y clang cmake g++ gcc lcov
      - name: Fetch coveralls
        if: matrix.flavor == 'Coverage'
        run: |
          pip install --user cpp-coveralls

      - name: Build & Run
        run: |
          cmake -DCMAKE_BUILD_TYPE=${{ matrix.flavor }} -DSUPPORT_STDIOSTREAM=ON -DTESTING=ON -DFORMAT=${{ matrix.compiler.FORMAT }} .
          make check

          # TODO: enable
#      - name: Coveralls build
#        if: matrix.flavor == 'Coverage'
#        run: |
#          cpp-coveralls -i matrix
#      - name: Coveralls
#        if: matrix.flavor == 'Coverage'
#        uses: coverallsapp/github-action@master
#        with:
#          github-token: ${{ secrets.GITHUB_TOKEN }}

